<template>
	<el-main>
		<el-row :gutter="15">
			<el-col :lg="12">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option"></scEcharts>
				</el-card>
			</el-col>
			<el-col :lg="12">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option2"></scEcharts>
				</el-card>
			</el-col>
			<el-col :lg="12">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option3"></scEcharts>
				</el-card>
			</el-col>
			<el-col :lg="12">
				<el-card shadow="never">
					<scEcharts height="300px" :option="option4"></scEcharts>
				</el-card>
			</el-col>
		</el-row>
	</el-main>
</template>

<script>
import scEcharts from '@/components/scEcharts';

/**
 * 引入组件 @/components/scEcharts
 * 组件内部会自动加载主题 @/components/scEcharts/echarts-theme-T.js
 * 支持props包括 height，width，option
 * 组件export百度Echarts所有方法，使用方式: new scEcharts[fun]
 */

export default {
	name: 'chart',
	components: {
		scEcharts
	},
	data() {
		return {
			option: {},
			option2: {title: {
					text: '项目类型统计',
				}},
			option3: {},
			option4: {title: {
					text: '费用类型统计',
				}},
		}
	},
	mounted() {
		this.getProSortPie();
		this.getProSortBar();
		this.getProCostTypePie();
		this.getProCostTypeBar();
	},
	methods:{
		async getProSortPie(){
			var res = await this.$API.project.echarts.getProSortPie.get();
			if (res.code == 200) {
				this.option = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getProSortBar(){
			var res = await this.$API.project.echarts.getProSortBar.get();
			if (res.code == 200) {
				this.option2 = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getProCostTypePie(){
			var res = await this.$API.project.echarts.getProCostTypePie.get();
			if (res.code == 200) {
				this.option3 = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getProCostTypeBar()
		{
			var res = await this.$API.project.echarts.getProCostTypeBar.get();
			if (res.code == 200) {
				this.option4 = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
	}
}
</script>

<style>
</style>
